<!--
  #%L
  thinkbig-ui-operations-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
      http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  #L%
  -->
<div flex layout="row">
    <card-layout flex>
        <header-section transclude-to="head" flex layout>
            <div style="white-space:nowrap" class="card-title" flex>{{vm.cardTitle}}</div>
        </header-section>
        <body-section transclude-to="body" transclude-replace="true">
            <md-content>
                <div layout="column" class="layout-padding-bottom layout-padding-left-16">
                    <div layout="row">
                        <div flex="20" layout="column">
                            <span class="column-title column-title-bottom">等级</span>
                            <span class="item-title">
                                {{vm.alertData.level}}
                            </span>
                        </div>

                        <div flex="50" layout="column">

                            <span class="column-title column-title-bottom">类型</span>
                            <span class="item-title">
                                {{vm.alertData.type}}
                            </span>
                        </div>

                        <div flex="30" layout="column">

                            <span class="column-title column-title-bottom">开始时间 </span>
                             <span class="item-title">
                                {{vm.alertData.createdTime | date:'yyyy-MM-dd hh:mm:ss'}}
                            </span>
                        </div>
                    </div>



                    <div class="item-title" style="padding-top:10px;padding-bottom:4px;">描述</div>
                    <div class="accent-color-3" style="font-size:16px;padding-top:4px;padding-bottom:25px;padding-right:16px;">{{vm.alertData.description}}</div>

                    <md-list class="list-item-table">
                        <md-divider></md-divider>
                        <md-list-item>
                            <div flex="60" class="item-column md-list-item-text accent-color-3">
                                提交动作
                            </div>
                            <div flex="15" class="item-column md-list-item-text accent-color-3">
                                用户
                            </div>
                            <div flex="25" class="item-column md-list-item-text accent-color-3">
                                创建时间
                            </div>
                            <md-divider></md-divider>
                        </md-list-item>
                        <md-list-item ng-repeat="item in vm.alertData.events | orderBy:'createTime'">
                            <div flex="60" class="item-column md-list-item-text" layout="column" ng-if="item.description.length > 0">
                                <span class="item-title" style="white-space: normal;">
                                    {{item.description}}
                                </span>
                                <span class="column-title column-title-bottom {{item.stateClass}}">
                                    <ng-md-icon icon="{{item.stateIcon}}" size="20"></ng-md-icon>
                                    {{item.stateText|fstatus}} {{item.contentSummary}}
                                </span>
                            </div>
                            <div flex="60" style="word-wrap:break-word;" class="item-column md-list-item-text {{item.stateClass}}" ng-if="item.description == null || item.description.length == 0">
                                <ng-md-icon icon="{{item.stateIcon}}" size="20"></ng-md-icon>
                                {{item.stateText|fstatus}} {{item.contentSummary}}
                            </div>
                            <div flex="15" style="word-wrap:break-word;" class="item-column md-list-item-text">
                                {{item.user}}
                            </div>
                            <div flex="25" style="word-wrap:break-word;" class="item-column md-list-item-text">
                                {{item.createdTime | date:'yyyy-MM-dd hh:mm:ss'}}
                            </div>
                            <md-divider ng-if="!$last"></md-divider>
                        </md-list-item>
                    </md-list>
                </div>
            </md-content>
        </body-section>
    </card-layout>

    <card-layout flex="30" header-css="job-details-header" body-css="job-details-right-body">
        <header-section transclude-to="head" flex layout>
            <div style="white-space:nowrap" class="card-title">告警概要</div>
            <span flex></span>
        </header-section>
        <body-section transclude-to="body">
            <md-content flex md-scroll-y>
                <div class="card-content">
                    <md-button ng-if="vm.alertData.actionable && vm.allowAdmin" class="border-btn action-btn" ng-click="vm.showEventDialog($event)">更新</md-button>
                    <md-button ng-if="vm.alertData.cleared == false && vm.allowAdmin" class="border-btn action-btn" ng-click="vm.hideAlert($event)">隐藏</md-button>
                    <md-button ng-if="vm.alertData.cleared == true && vm.allowAdmin" class="border-btn action-btn" ng-click="vm.showAlert($event)">显示</md-button>
                </div>

                <md-list flex layout-fill layout="column" class="list-item-table">
                    <md-list-item>
                        <div layout="column" class="item-column md-list-item-text">
                            <span class="column-title column-title-bottom">状态</span>
                            <span class="item-title {{vm.alertData.stateClass}}">
                                <ng-md-icon icon="{{vm.alertData.stateIcon}}" size="20"></ng-md-icon>
                                {{vm.alertData.stateText|fstatus}}
                            </span>

                        </div>
                    </md-list-item>
                    <md-divider></md-divider>
                    <md-list-item>
                        <div layout="column"  class="item-column md-list-item-text ">
                            <span class="column-title column-title-bottom">创建以来</span>
                            <span class="item-title">
                                <kylo-timer start-time="vm.alertData.createdTimeSince"></kylo-timer>
                            </span>

                        </div>
                    </md-list-item>
                </md-list>
                <md-divider></md-divider>
                <div layout="column" class="layout-padding-top-bottom" layout-align="space-between start" ng-if="vm.alertData.links.length >0" style="padding-left:25px">

                    <div class="md-subheader layout-padding-bottom">链接</div>
                    <div ng-repeat="link in vm.alertData.links" layout="column" class="layout-padding-bottom">
                        <a ui-sref="{{link.value}}">{{link.label}}</a>
                    </div>
                </div>
            </md-content>
        </body-section>
    </card-layout>
</div>
